package user

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/userServiceClient/userrpc"
	"github.com/zeromicro/go-zero/core/logx"
)

type UserGroupCreateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewUserGroupCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserGroupCreateLogic {
	return &UserGroupCreateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserGroupCreateLogic) UserGroupCreate(req *types.UserGroupCreateRequest) (resp *types.UserGroupCreateResponse, err error) {
	_, err = l.svcCtx.UserServiceRPC.UserGroupCreate(l.ctx, &userrpc.UserGroupCreateRequest{
		GroupName:      req.GroupName,
		RechargeAmount: req.RechargeAmount,
		RechargeTimes:  int64(req.RechargeTimes),
		OrderAmount:    req.OrderAmount,
		Perms:          req.Perms,
	})
	if err != nil {
		return
	}
	resp = &types.UserGroupCreateResponse{}
	return
}
